package io.renren.modules.app.service.impl;

import io.renren.modules.app.dao.GoodsDao;
import io.renren.modules.app.entity.GoodsEntity;
import io.renren.modules.app.service.GoodsService;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;


@Service("goodsService")
public class GoodsServiceImpl extends ServiceImpl<GoodsDao, GoodsEntity> implements GoodsService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        // 接受查询参数
        // 查询数据 并返回
        IPage<GoodsEntity> page = this.page(
                new Query<GoodsEntity>().getPage(params),
                new QueryWrapper<GoodsEntity>()
                        .like("name", params.get("key"))
                        .or().like("intro", params.get("key"))
                        .or().like("price", params.get("key"))
        );

        return new PageUtils(page);
    }

}
